var rootPath = getRootPath();

$(function(){
	$('#realNameInfoTable').DataTable({
        "language": {
        	"lengthMenu": "每页 _MENU_ 条记录",
            "zeroRecords": " ",
            "info": "当前 _START_ 条到 _END_ 条 &nbsp;&nbsp;&nbsp;共 _TOTAL_ 条记录",
            "infoEmpty": "无记录",
            "infoFiltered": "",//(从 _MAX_ 条记录过滤)
            "search": "搜索",
            "processing": "载入中",
            "paginate": {
                "first": "首页",
                "previous": "上一页",
                "next": "下一页",
                "last": "尾页"
            }
        },

        serverSide: true,
        info: true,
        lengthChange: false,//是否允许用户改变表格每页显示的记录数
        ordering: true,//是否允许用户排序
        paging: true,//是否分页
        processing: true,
        searching: true,
        pagingType: "simple_numbers",//除首页、上一页、下一页、末页四个按钮还有页数按钮
        stateSave: false,//刷新时是否保存状态
        autoWidth: true,//自动计算宽度
        orderMulti: true,
        pageLength: 10,
        order: [[0,'asc']],
        fnInitComplete:function(){
        },
		"ajax" : {
			"type": "POST",
			"url": rootPath + '/realNameAuth/queryAuthByDataTable',
			"dataType":'json',
			"contentType": "application/json",
		    "data": function ( d ) {
		    	return JSON.stringify( d );
		    }
		},
		"columns" : [ {
			"name" : "uid",
			"data" : "uid"
		},
		{
			"name" : "realName",
			"data" : "realName"	
		},
		{
			"name" : "creType",
			"data" : null,
			"render": function (data,type,row,meta) {
				var s = "";
				var creType = data.creType;
				if(creType != undefined){
					if(creType == 0){
						s = "身份证";
					} else if(creType == 1){
						s = "护照";
					} else if(creType == 2){
						s = "其他";
					} else {
						//未知
					}
				}
				return s;
			}
		},
		{
			"name" : "creNum",
			"data" : "creNum"	
		},
		{
			"name" : null,
			"data" : null,
			"render": function (data,type,row,meta) {
				var	rlt =  "<i class='iconfont ml-5 marginLeft12' style='cursor: pointer;' title='详情' onclick=auth_show('详情','authInfoShowPage?uid="+ data.uid +"','','')>&#xe60c;</i>"
				rlt +=  "<i class='iconfont ml-5 marginLeft12' style='cursor: pointer;' title='下载照片' onclick=download('"+ data.uid +"')>&#xe615;</i>"
				return rlt;
			}
		}
		]
	});
	$("#realNameInfoTable").find('tbody').addClass('tableTR');
});

function auth_show(title,url,w,h){
	layer_show(title,url,w,h);
}
function download(uid){
	window.open("realNameAuth/downloadPic?uid="+uid);
}